<?php
	error_reporting (E_ALL ^ E_NOTICE);
	include "./config/conn_database.php";
	if(trim($_FILES["fileUpload"]["tmp_name"]) != ""){
		$images = $_FILES["fileUpload"]["tmp_name"];
		$new_images = "gallery_".$_FILES["fileUpload"]["name"];
		$strSQL="INSERT INTO wed_product (pro_id, pro_filename, typ_id) VALUES (NULL, '".$new_images."', '".$_POST["typepro"]."')";
		$objQuery = mysql_query($strSQL);
		copy($_FILES["fileUpload"]["tmp_name"],"./images/product/".$new_images);
		echo "<meta http-equiv='refresh' content='0; url=admin_product.php'>";
	}else{
		$strSQL="DELETE FROM wed_product WHERE pro_filename = '".$_GET["fileName"]."'";
		$objQuery = mysql_query($strSQL);
		$strUnlink = "./images/product/".$_GET["fileName"] ;
		unlink($strUnlink);
		echo "<meta http-equiv='refresh' content='0; url=admin_product.php'>";		
	}
	mysql_close($objConnect);
?>